import { createReducer } from '../utils/index';
import { SEND_MESSAGE_REQUEST, SEND_MESSAGE_SUCCESS, SEND_MESSAGE_FAILURE, BAN_RESEND_MESS } from '../contants/index';

const initialState = {
	isSending: false,
	isSended: false,
	count: 60
};
export default createReducer(initialState, {
	[SEND_MESSAGE_REQUEST]: (state, payload) => {
		return Object.assign({}, state, {
            'isSending': true,
            'statusText': '正在发送...'
		})
	},
	[SEND_MESSAGE_SUCCESS]: (state, payload) => {
		return Object.assign({}, state, {
			'isSending': false,
			'isSended': true,
		})
	},
	[SEND_MESSAGE_FAILURE]: (state, payload) => {
		return Object.assign({}, state, {
			'isSending': false,
			'isSended': false,
		})
	},
	[BAN_RESEND_MESS]: (state, payload) => {
		return Object.assign({}, state, {
			'count': payload.count
		})
	}

})